<template>
  <div>
    <el-dialog title="修改用户" :visible.sync="thistype" @close="fun(tname)">
      <el-form label-width="80px" :model="form" ref="form">
        <el-form-item label="用户昵称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="入学状态">
            <el-select v-model="form.school" placeholder="请选择">
                <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
            </el-select>
            <!-- <el-input v-model="form.school"></el-input> -->
          <!-- <el-radio-group v-model="form.school " >
            <el-radio label="1">入学</el-radio>
            <el-radio label="2">未入学</el-radio>
          </el-radio-group> -->
        </el-form-item>
      </el-form>
      <!-- {{form.school}} -->
      <div slot="footer" class="dialog-footer">
        <el-button @click="thistype = false">取 消</el-button>
        <el-button type="primary" @click="upuser">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ['type', 'fun', 'tname', 'tablerow'],
  data () {
    return {
      thistype: this.type, // 模态框状态
      form: {
        name: '', // 用户呢称
        school: '' // 入学状态 入学：el-icon-check 未入学：el-icon-close
      },
      options: [{
        value: '入学',
        label: '入学'
      }, {
        value: '未入学',
        label: '未入学'
      }]
    }
  },

  methods: {
    // 修改用户信息，判断用户信息是否填写完整
    upuser () {
      this.thistype = false
      var type = true
      for (var i in this.form) {
        if (this.form[i] === '') {
          type = false
        }
      }
      if (type) {
        // 请求接口并传递数据
        // for (var j in this.form) {
        //   this.form[j] = ''
        // }
      } else {
        this.thistype = true
        this.$message.error('请补全信息')
      }
    }
  },
  watch: {
    type () {
      this.thistype = this.type
    },
    tablerow () {
      this.form = this.tablerow
    }
  }
}
</script>

<style>
</style>
